﻿package top.yangyitao.action;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;

import top.yangyitao.model.User;
import top.yangyitao.service.UserService;

/**
 * @author Eetal
 */
@Controller
public class LoginCheck extends ActionSupport{

	private static final long serialVersionUID = 1L;
	@Resource
	private UserService userService; 
	private User user;
	private String errorMessage;
	public String getErrorMessage() {
		return errorMessage;
	}
	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	@Override
	public String execute() throws Exception {
		switch(userService.userLoginCheck(user)) {
		case SUCCESS : return SUCCESS;
		case WRONGPWD : errorMessage = "*密码有误!";return ERROR; 
		case USERNOTEXIT : errorMessage = "*用户名不存在!";return ERROR;
		case UNACTIVE : errorMessage = "*该账户尚未进行激活验证";return ERROR;
		default : break;
		}
		return null;
	}

}
